package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import net.sf.json.JSONObject;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name = "qso_vm")
public class Vm extends BaseEntity
{

	private static final long serialVersionUID = 1600586883410955314L;

	private String id = null;

	private String ip = null;
	
	private String port = null;

	private String pwd = null;

	private String mac = null;

	private String name = null;

	private String ad = null;

	private String desc = null;

	private String isEnable = "F";

	public Vm() {
		super();
	}
	
	public Vm(String id,String ip,String port,String pwd){
		this.id=id;
		this.ip=ip;
		this.port=port;
		this.pwd=pwd;
	}

	@Id
	@GenericGenerator(name = "idGen", strategy = "com.wits.platform.common.id.generator.IDGenerator", parameters = {
	        @Parameter(name = "segment_value", value = "QSO_VM_ID"),
	        @Parameter(name = "table_name", value = "wits_id_generator"),
	        @Parameter(name = "value_column_name", value = "gen_value"), 
	        @Parameter(name = "segment_column_name", value = "gen_name"),
	        @Parameter(name = "segment_value_length", value = "5"), 
	        @Parameter(name = "sq_format", value = "%03d"),
	        @Parameter(name = "sq_prefix", value = "CL") })
	@GeneratedValue(generator = "idGen")
	@Column(name = "vm_id", nullable = false, insertable = true, updatable = false, length = 50)
	public String getId() {
		return id;
	}

	@Column(name = "vm_ip", nullable = false, length = 30)
	public String getIp() {
		return ip;
	}

	@Column(name = "vm_port", nullable = false, length = 5)
	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}
	
	@Column(name = "vm_pwd", nullable = false, length = 20)
	public String getPwd() {
		return pwd;
	}

	@Column(name = "vm_mac", nullable = true, length = 20)
	public String getMac() {
		return mac;
	}

	@Column(name = "vm_name", nullable = false, length = 50)
	public String getName() {
		return name;
	}

	@Column(name = "vm_ad", nullable = true, length = 50)
	public String getAd() {
		return ad;
	}

	@Column(name = "vm_desc", nullable = true, length = 255)
	public String getDesc() {
		return desc;
	}

	@Column(name = "is_enable", nullable = false, length = 1)
	public String getIsEnable() {
		return isEnable;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAd(String ad) {
		this.ad = ad;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public void setIsEnable(String isEnable) {
		this.isEnable = isEnable;
	}

	// public static List<Vm> getVmList(){
	// List<Vm> list=new ArrayList<Vm>();
	// Vm vm=new Vm("11","10.6.1.19","5900","123");
	// list.add(vm);
	// return list;
	// }
	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	public String toString() {
		return JSONObject.fromObject( this, Vm.getBaseJsonConfig() ).toString();
	}
	// public static Vm getOne() {
	// return new Vm("11","10.6.1.19","5900","123");
	// }
}
